<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>The main page</title>
</head>
<body>
	<c:choose>
		<c:when test="${not empty listPerson}">
			<h3>List person</h3>
			<table>
				<thead>
					<tr style="color: blue">
						<th>FirstName</th>
						<th>LastName</th>
						<th>Age</th>
						<th>Address</th>
						<th>Action</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${listPerson}" var="person">
						<c:url var="editUrl" value="/main/persons/edit?id=${person.id}"></c:url>
						<c:url var="deleteUrl"
							value="/main/persons/delete?id=${person.id}"></c:url>
						<tr>
							<td><c:out value="${person.firstName}"></c:out></td>
							<td><c:out value="${person.lastName}"></c:out></td>
							<td><c:out value="${person.age}"></c:out></td>
							<td><c:out value="${person.address}"></c:out></td>
							<td><a href="${editUrl }">Edit</a>|<a href="${deleteUrl }"
								onclick="return confirm('Do you really want to delete this person?')">Delete</a></td>
						</tr>
					</c:forEach>
					<tr>
						<td><c:url var="addUrl" value="/main/persons/add"></c:url>
							Click <a href="${addUrl }">here</a> to add a new person</td>
					</tr>
				</tbody>
			</table>
		</c:when>
		<c:otherwise>
			<c:url var="addUrl" value="/main/persons/add"></c:url>
	Click <a href="${addUrl }">here</a> to add a new person
	</c:otherwise>
	</c:choose>
</body>
</html>